<?php

declare(strict_types=1);

namespace app\yperp\command;

use app\yperp\common\ChanghongList;
use app\yperp\common\MyWebDriver;
use app\yperp\common\Redis;
use app\yperp\model\Supplier;
use Fairy\Html2WordMaker;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\Output;
use think\Db;
use think\Queue;

use PhpOffice\PhpWord\IOFactory;
use PhpOffice\PhpWord\Shared\Html;

class test extends Command
{


    protected $output;

    protected $input;
    protected $driver;
    protected $windows = [];
    protected $cookies = [];
    protected function configure()
    {
        // 指令配置
        $this->setName('test')
            ->setDescription('测试命令：test');
    }

    protected function execute(Input $input, Output $output)
    {
        try {
            //code...

            // HTML内容
            // $htmlContent = '<h1>Hello World</h1><p>This is a test paragraph.</p>';
            // $htmlContent = file_get_contents(env('root_path') . 'public/test.html');

            Html2WordMaker::getInstance()->addFile(env('root_path') . 'public/test.html')->fetchImg()->download("这是一个名称");

            // dump($htmlContent);
            // // 创建一个新的Word文档
            // $phpWord = new \PhpOffice\PhpWord\PhpWord();

            // // 添加一个新的空白页
            // $section = $phpWord->addSection();

            // // 将HTML内容添加到文档中
            // Html::addHtml($section, $htmlContent);

            // // 写入Word文档
            // $writer = IOFactory::createWriter($phpWord, 'Word2007');
            // $writer->save(env('root_path') . 'runtime/example.docx');

            echo 'Word文档已生成。';
        } catch (\Throwable $th) {
            dump($th->getMessage());
            dump($th->getTraceAsString());
        }








        // // 指令输出
        // $this->input = $input;

        // $this->output = $output;
        // MyWebDriver::getInstance()->run([
        //     ['type' => 'this', 'do' => ['this_method' => 'WebDriver', 'fastrun' => true],  'sleep' => 3],
        //     ['type' => 'open', 'do' => ['url' => 'https://www.baidu.com'], 'sleep' => 1],
        // ]);
    }
}
